import React, { Component } from 'react'
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import Login from './pages/Login';
import Nav from './pages/nav';
const Home=React.lazy(()=>import('./pages/Home'))
const AddAccount=React.lazy(()=>import('./pages/accounts/AddAccount'))
const AccountsList=React.lazy(()=>import('./pages/accounts/AccountsList'))
const AddShop=React.lazy(()=>import('./pages/shop/AddShop'))
const ShopList=React.lazy(()=>import('./pages/shop/ShopList'))
export default class App extends Component {
  render() {
    return (
      <React.Suspense fallback={<div>加载中</div>}>
        <BrowserRouter>
          <Routes>
            <Route path='/' element={<Navigate to='/login'></Navigate>}></Route>
            <Route path='/login' element={<Login></Login>}></Route>
            <Route path='/nav' element={<Nav></Nav>}>
              <Route path='home' element={<Home></Home>}></Route>
              <Route path="shopList" element={<ShopList />} />
              <Route path="addShop" element={<AddShop />} />
              <Route path="accountsList" element={<AccountsList />} />
              <Route path="addAccount" element={<AddAccount />} />
            </Route>
          </Routes>
        </BrowserRouter>
      </React.Suspense>
    )
  }
}

